#include<stdio.h>
#include<malloc.h>
#include"..\Link_List\zyf_link_List.h"
typedef int ElemType;

void del_x_linklist(LNode *L,int x)
{
	LNode *p,*q;
	p = L;

	if (p -> data != x && p -> next != NULL)
		del_x_linklist(p -> next,x);
	else if (p -> next != NULL)
	{
		q = p;
		p = p -> next;
		free(q);
		del_x_linklist(p,x);
	}
}

void sort1(LNode *L)
{
	LNode *p = L -> next,*pre;
	LNode *r = p -> next;
	p -> next =NULL;
	p = r;
	while(p!=NULL)
	{
		r = p -> next;
		pre =L;
		while (pre->next!=NULL&&pre->next->data<p->data)
			pre=pre->next;
		p -> next = pre -> next;
		pre -> next = p;
		p = r;
	}
}

void sort2(LNode *L)
{
	LNode *p = L -> next,*q,*r;
	r = p -> next;
	q = L;

	while (p -> next != NULL)
	{

		if (p -> data > r -> data)
		{
			q -> next = r;
			p -> next = r -> next;
			r -> next = p;
			q = r;
			r = p -> next;
		}
		else
		{
			q = p;
			p = r;
			r = p -> next;
		}
		
	}
}


void R_LinkList2(LNode *L)
{
	LNode *p,*r,*q;
	p = L -> next;
	r = p -> next;

	L -> next = NULL;

	while (r != NULL)
	{
		q = p;
		p = r;
		r = p -> next;
		p -> next = q;
	}

	L -> next = p;
}

int main(void)
{
	struct Lnode *a;
	a = create_LinkList2();
	for (int i = 1;i < 6;i++)
	{
		printf("第%d个值为%d\n",i,Get_Elem(a,i));
	}

	R_LinkList2(a);

	for (int i = 1;i < 6;i++)
	{
		printf("----------第%d个值为%d\n",i,Get_Elem(a,i));
	}

}